/**
 * Created by chengcong on 2017/12/13.
 */
var url='http://120.27.161.98:6655';
$(function () {
    var browser = {
        versions: function() {
            var u = navigator.userAgent;
            return {
                trident: u.indexOf('Trident') > -1, //IE内核
                presto: u.indexOf('Presto') > -1, //opera内核
                webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                gecko: u.indexOf('Firefox') > -1, //火狐内核Gecko
                mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
                android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
                iPhone: u.indexOf('iPhone') > -1 , //iPhone
                iPad: u.indexOf('iPad') > -1, //iPad
                webApp: u.indexOf('Safari') > -1 //Safari
            };
        }()
    }
    console.log(browser);
    if(browser.versions.trident){
        $.ajax({
            url:url+'/api/WebPage/GetJobFilterList',
            type:'post',
            data:{classid:15},
            success:function (data) {
                $('.yon-yd').html('')
                if(data.code==200){
                    for(var i=0;i<data.data.length;i++){
                        data.data[i].Requirement=data.data[i].Requirement.split('\r\n').join('<br/>');
                        if((Math.ceil((i+1)/2)%2)>0){
                            $('.yon-yd').append('<div class="flip-container col-md-6">' +
                                '<div class="flipper">' +
                                '<div class="front" dataid="'+data.data[i].id+'" onmouseover="backshow('+data.data[i].id+')">' +
                                '<div class="col-md-6 yon-yt">' +
                                '<img src="http://120.27.161.98:6677/'+data.data[i].jobimg+'" alt="...">' +
                                '</div>' +
                                '<div class="col-md-6">' +
                                '<a href="javascript:void(0);">' +
                                '<h2>'+data.data[i].Position+'</h2>' +
                                '<p>' +
                                '<img src="../img/rencaitt1.png" alt="...">' +
                                '</p>' +
                                '</a>' +
                                '</div></div>' +
                                '<div class="back" data2id="'+data.data[i].id+'" onmouseleave="frontshow('+data.data[i].id+')" style="display: none;z-index: 2"><div class="col-md-12 yon-yd-son" style="height: 600px">' +
                                '<h1>'+data.data[i].Position+'</h1><h2></h2><p>'+data.data[i].Requirement+'</p>' +
                                '<a href="'+data.data[i].LinkUrl+'">详细要求</a></div></div>' +
                                '</div>' +
                                '</div>')
                        }else{
                            $('.yon-yd').append('<div class="flip-container col-md-6">' +
                                '<div class="flipper">' +
                                '<div class="front" dataid="'+data.data[i].id+'" onmouseover="backshow('+data.data[i].id+')">' +
                                '<div class="col-md-6 yon-yt">' +
                                '<img src="http://120.27.161.98:6677/'+data.data[i].jobimg+'" alt="...">' +
                                '</div>' +
                                '<div class="col-md-6">' +
                                '<a href="javascript:void(0);" style="background: #fff">' +
                                '<h2 style="color: #444">'+data.data[i].Position+'</h2>' +
                                '<p>' +
                                '<img src="../img/rencaitt2.png" alt="...">' +
                                '</p>' +
                                '</a>' +
                                '</div></div>' +
                                '<div class="back" style="display: none;z-index: 2" data2id="'+data.data[i].id+'" onmouseleave="frontshow('+data.data[i].id+')"><div class="col-md-12 yon-yd-son" style="height: 600px">' +
                                '<h1>'+data.data[i].Position+'</h1><h2></h2><p>'+data.data[i].Requirement+'</p>' +
                                '<a href="'+data.data[i].LinkUrl+'">详细要求</a></div></div>' +
                                '</div>' +
                                '</div>')
                        }
                    }

                }
                console.log(data);

            }
        });
    }else{
        $.ajax({
            url:url+'/api/WebPage/GetJobFilterList',
            type:'post',
            data:{classid:15},
            success:function (data) {
                $('.yon-yd').html('')
                if(data.code==200){
                    for(var i=0;i<data.data.length;i++){
                        data.data[i].Requirement=data.data[i].Requirement.split('\r\n').join('<br/>');
                        if((Math.ceil((i+1)/2)%2)>0){
                            $('.yon-yd').append('<div class="flip-container2 col-md-6" style="z-index: 1">' +
                                '<div class="flipper2">' +
                                '<div class="front2">' +
                                '<div class="col-md-6 yon-yt">' +
                                '<img src="http://120.27.161.98:6677/'+data.data[i].jobimg+'" alt="...">' +
                                '</div>' +
                                '<div class="col-md-6">' +
                                '<a href="javascript:void(0);">' +
                                '<h2>'+data.data[i].Position+'</h2>' +
                                '<p>' +
                                '<img src="../img/rencaitt1.png" alt="...">' +
                                '</p>' +
                                '</a>' +
                                '</div></div>' +
                                '<div class="back2"><div class="col-md-12 yon-yd-son" style="height: 600px">' +
                                '<h1>'+data.data[i].Position+'</h1><h2></h2><p>'+data.data[i].Requirement+'</p>' +
                                '<a href="'+data.data[i].LinkUrl+'">详细要求</a></div></div>' +
                                '</div>' +
                                '</div>')
                        }else{
                            $('.yon-yd').append('<div class="flip-container2 col-md-6" style="z-index: 1">' +
                                '<div class="flipper2">' +
                                '<div class="front2">' +
                                '<div class="col-md-6 yon-yt">' +
                                '<img src="http://120.27.161.98:6677/'+data.data[i].jobimg+'" alt="...">' +
                                '</div>' +
                                '<div class="col-md-6">' +
                                '<a href="javascript:void(0);" style="background: #fff">' +
                                '<h2 style="color: #444">'+data.data[i].Position+'</h2>' +
                                '<p>' +
                                '<img src="../img/rencaitt2.png" alt="...">' +
                                '</p>' +
                                '</a>' +
                                '</div></div>' +
                                '<div class="back2"><div class="col-md-12 yon-yd-son" style="height: 600px">' +
                                '<h1>'+data.data[i].Position+'</h1><h2></h2><p>'+data.data[i].Requirement+'</p>' +
                                '<a href="'+data.data[i].LinkUrl+'">详细要求</a></div></div>' +
                                '</div>' +
                                '</div>')
                        }

                    }
                    $('.flip-container2').on('mouseover',function () {
                        $(this).siblings().css('zIndex','-2')
                    });
                    $('.flip-container2').on('mouseleave',function () {
                        $(this).siblings().css('zIndex','0')
                    })

                }
                console.log(data);

            }
        });
    }

})
function backshow(id) {
    $('div[dataid="'+id+'"]').css('opacity',0);
    $('div[dataid="'+id+'"]').parent().parent().siblings().children().children('.back').hide();
    $('div[dataid="'+id+'"]').parent().parent().siblings().children().children('.front').css('opacity',1);
    $('div[dataid="'+id+'"]').next('.back').show( "drop", 500);
    $('div[data2id="'+id+'"]').parent().parent().css('zIndex',5);
}
function frontshow(id) {
    $('div[data2id="'+id+'"]').hide( "drop", 500);
    $('div[data2id="'+id+'"]').prev('.front').css('opacity',1);
    $('div[data2id="'+id+'"]').parent().parent().css('zIndex',1);
}
